package com.seafwg.ssm.controller;

import com.seafwg.ssm.domain.Account;
import com.seafwg.ssm.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author seafwg
 * @Date 2022/3/18 9:50 上午
 * @Version 1.0
 * @description xxx
 */
@Controller
@CrossOrigin
@ResponseBody
@RequestMapping("/ssm")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @RequestMapping(value = "/findAll")
    public List<Account> findAll() {
        List<Account> accountList = accountService.findAll();
        return accountList;
    }

    @RequestMapping("/findAccount")
    public List<Account> findAll1() {
        List<Account> accountList = accountService.findAll1();
        return accountList;
    }

    // 使用RESTful接口请求地址，参数使用@PathVariable注解接收
    @RequestMapping("/find/{id}")
    public Account findId(@PathVariable("id") int id) {
        Account account = accountService.findAccountById(id);
        return account;
    }
}
